'use strict';

module.exports = app => {
  if (app.config.env === 'local') {
    app.beforeStart(async () => {
      await app.model.sync();
      if (await app.model.Config.count() === 0) {
        const configDefaultValues = [
          {
            key: 'about',
            name: '关于我们',
            type: 'html',
          },
          {
            key: 'user',
            name: '用户协议',
            type: 'html',
          },
          {
            key: 'helpAndFeedback',
            name: '帮助反馈',
            type: 'html',
          },
          {
            key: 'CustomerServicePhone',
            name: '客服电话',
            type: 'integer',
          },
          {
            key: 'platformCommissionRatio',
            name: '平台分成',
            type: 'decimal5with5',
          },
          {
            key: 'facilitatorCommissionRatio',
            name: '服务商分成',
            type: 'decimal5with5',
          },
          {
            key: 'memberCommissionRatio',
            name: '会员佣金抽水',
            type: 'decimal5with5',
          },
        ];
        await app.model.Config.bulkCreate(configDefaultValues);
      }
    });
  }
};
